<template>
  <div id="shareTopSearch">
    <h1 class="con-right-title">
      多渠道URL配置
    </h1>
    <div class="search-box">
      <el-form
        ref="formInline"
        :inline="true"
        :model="formInline"
        :rules="rules"
        class="demo-form-inline"
      >
        <el-form-item label="活动名称：" prop="activityId">
          <el-select
            v-model="formInline.activityId"
            filterable
            placeholder="请选择活动名称"
          >
            <el-option
              v-for="item in activeList"
              :key="item.id"
              :label="item.activityName"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <!-- 输入搜索部分 -->
        <el-form-item label="推广渠道名称：" prop="channelName">
          <el-input
            clearable
            v-model="formInline.channelName"
            placeholder="请输入推广渠道名称"
            size="small"
            class="numberInput"
          ></el-input>
        </el-form-item>
        <el-form-item label="推广渠道名称编号：" prop="channelNum">
          <el-input
            clearable
            v-model="formInline.channelNum"
            placeholder="请输入推广渠道名称编号"
            size="small"
            class="numberInput"
          ></el-input>
        </el-form-item>
        <el-form-item class="s-btn">
          <el-button
            type="success"
            icon="el-icon-search"
            @click="toSearch('formInline')"
          >
            查询
          </el-button>
          <el-button type="success" plain @click="reset">
            重置
          </el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  name: 'channelsTopSearch',
  msg: '多渠道URL配置-顶部搜索',
  props: {
    activeList: {
      type: Array,
      default() {
        return []
      }
    },
    formInline: {
      type: Object,
      default: function() {
        return {
          activityId: '', //活动id
          channelName: '', // 推广渠道名称
          channelNum: '' // 推广渠道名称编号
        }
      }
    }
  },
  data() {
    return {
      rules: {
        type: {},
        collegeId: {},
        title: {}
      }
    }
  },
  mounted() {},
  methods: {
    /* 搜索 */
    toSearch(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$emit('toSearch')
        } else {
          return false
        }
      })
    },
    /* 重置 */
    reset() {
      this.$refs['formInline'].resetFields()
    }
  }
}
</script>
